package logic.nodes.damagable.shield;

import logic.nodes.damagable.DamagableNode;

import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.TriMesh;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.TextureState;

import fileHandling.TextureLoader;

public class ShieldQuad extends ShieldEffectObject {
	
	private static final long serialVersionUID = 1L;
	
	public ShieldQuad(DamagableNode node, Shields shields, Vector3f location, float maxDist) {
		super(node, shields, location, maxDist);
	}
	
	@Override
	protected TriMesh getObject() {
		String name = "shield quad of " + node.getName();
		float width = maxDist * 2f;
		float height = width;
		Quad quad = new Quad(name, width, height);
		quad.lookAt(location, Vector3f.UNIT_Y.clone(), true);
		quad.setDefaultColor(ColorRGBA.blue);
		quad.setLocalTranslation(location);
		
		TextureState ts = TextureLoader.getTextureState("data/textures/effects/shield.png");
		quad.setRenderState(ts);
		
		return quad;
	}
	
	@Override
	public void setAlpha(float alpha) {
		object.getDefaultColor().a = 1f - alpha;
	}
}